<?php

namespace App\Http\Controllers\cert;

use Illuminate\Http\Request;
use App\Models\Cert;
use App\Http\Requests\CertRequest;
use App\Http\Controllers\Controller;

class CertController extends Controller
{
    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 分页列表
     * @description
     * @method get
     * @url /cert/cert
     * @param Demo 必选 string 例子
     * @return {}
     * @return_param cert_id int 
     * @return_param cert_no int 
     * @return_param updated_at datetime 更新时间
     * @return_param created_at datetime 创建时间
     * @return_param deleted_at datetime 删除时间
     * @return_param pet_name varchar 宠物名字
     * @return_param province varchar 省
     * @return_param birthday date 生日
     * @return_param sex varchar 性别
     * @return_param big_cat varchar 类别
     * @return_param cert_images text 
     * @return_param cert_people_info varchar 宠物主人信息
     * @return_param vaccine_info text 
     * @return_param Insect_info text 
     * @return_param demo int 例子
     * @remark 这里是备注信息
     * @number 99
     */
    public function index(Request $request)
    {
         $pageData = Cert::orderBy('created_at','DESC')->paginate(15);

         return $this->pageList($pageData);
    }

    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 获取全部数据
     * @description
     * @method get
     * @url /cert/cert/all
     * @return {}
     * @remark 这里是备注信息
     * @number 99
     */
    public function all(Request $request)
    {
         return Cert::all();
    }
    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 新增数据
     * @description
     * @method post
     * @url /cert/cert
     * @return {}
     * @remark 这里是备注信息
     * @number 99
     */
    public function store(CertRequest $request)
    {
        $cert = Cert::create($request->all());
        if($cert){
           return $this->success($cert);
        }else{
         return $this->error($cert);
        }


    }

    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 获取索引为99的数据
     * @description
     * @method get
     * @url /cert/cert/99
     * @return {}
     * @remark 这里是备注信息
     * @number 99
     */
    public function show(Cert $cert)
    {
        return $this->success($cert);
    }

    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 更新数据索引为99的数据
     * @description
     * @method put
     * @url /cert/cert/99
     * @return {}
     * @remark 这里是备注信息
     * @number 99
     */
    public function update(CertRequest $request, Cert $cert)
    {
         $res =$cert->update($request->all());
         if(!$res){
           return $this->error();
         }else{
           return $this->success();
         }

    }

    /**
     * showdoc
     * @catalog cert模块/Cert功能
     * @title 删除索引为99的数据
     * @description
     * @method delete
     * @url /cert/cert/99
     * @return {}
     * @remark 这里是备注信息
     * @number 99
     */
    public function destroy(Cert $cert)
    {
        $res =$cert->delete();
        if(!$res){
           return $this->error();
         }else{
           return $this->success();
         }
    }
}
